<?php
/*
 * EImageFinder widget
 * Based on CKFinder (http://ckfinder.com/)
 *
 * @usage $this->widget('ext.finder.EImageFinder',array('fieldName'=>'my_field'));
 *
 * @author: Cassiano Surek <cass@surek.co.uk>
 */

class EImageFinder extends CInputWidget
{

	public $model;
	public $fieldName;
//	private $uploadURL;
//	private $uploadDir;
    protected $path;
    public $type;

    public function init()
    {

//		// Please change the config below to suit your needs
//		$this->uploadURL = dirname(Yii::app()->request->scriptFile) .'/files/';
//		$this->uploadDir = Yii::app()->getRequest()->hostInfo. Yii::app()->baseUrl.'/files/';

	   	// We need to make the CKFinder accessible, let's publish it to the assets folder
// 		$lo_am = new CAssetManager;
// 		$this->path = Yii::app()->getAssetManager()->publish(Yii::app()->basePath . '/extensions/kcfinder/kcfinder',true);
        parent::init();
    }

    public function run()
    {
        $this->render("kcfinder", array(
        		'model'=>$this->model,
                'fieldName'=>$this->fieldName,
                'path'=>$this->path,
        		'type'=>$this->type,
            ));
    }
}